import Vue from 'vue'
import Router from 'vue-router'
import workDetail from '@/views/work/workDetail'
Vue.use(Router)
import Layout from '@/layout'
import { errorLog } from '@/settings'
const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: channgeRoutes()
})
export function channgeRoutes() {
  let city = localStorage.getItem('cityName')
  return [
    {
      path: '/',
      redirect: '/work/departmentList'
    },
    {
      path: '/view',
      component: () => import('@/views/view/index'),
      hidden: true,
      name: 'view',
      meta: { title: '数智化工作台', keepAlive: true }
    },
    {
      path: '/userList',
      component: () => import('@/views/work/userList'),
      hidden: true,
      name: 'userList',
      meta: { title: '用户管理', icon: 'el-icon-s-tools' }
    },
    {
      path: '/projectTable',
      component: () => import('@/views/tableList/projectTable'),
      hidden: true,
      name: '项目情况列表',
      meta: { title: '项目情况列表' }
    },
    {
      path: '/warnTable',
      component: () => import('@/views/tableList/warnTable'),
      hidden: true,
      name: '政务外网商机预警',
      meta: { title: '政务外网商机预警' }
    },
    {
      path: '/warnTableCloud',
      component: () => import('@/views/tableList/warnTableCloud'),
      hidden: true,
      name: '政务云商机预警',
      meta: { title: '政务云商机预警' }
    },
    {
      path: '/dqytList',
      component: () => import('@/views/tableList/dqytList'),
      hidden: true,
      name: '特色客户商机清单',
      meta: { title: '特色客户商机清单' }
    }, {
      path: '/governmentTable',
      component: () => import('@/views/tableList/governmentTable'),
      hidden: true,
      name: '数字政府',
      meta: { title: '数字政府' }
    },
    {
      path: '/customerList',
      component: () => import('@/views/tableList/customerList'),
      hidden: true,
      name: '政务外网客户清单',
      meta: { title: '政务外网客户清单' }
    },
    {
      path: '/customerListCloud',
      component: () => import('@/views/tableList/customerListCloud'),
      hidden: true,
      name: '政务云客户清单',
      meta: { title: '政务云客户清单' }
    },
    {
      path: '/businessOpportunitiesList',
      component: () => import('@/views/tableList/businessOpportunitiesList'),
      hidden: true,
      name: '政务外网商机清单',
      meta: { title: '政务外网商机清单' }
    },
    {
      path: '/businessOpportunitiesListCloud',
      component: () => import('@/views/tableList/businessOpportunitiesListCloud'),
      hidden: true,
      name: '政务云商机清单',
      meta: { title: '政务云商机清单' }
    },
    {
      path: '/mgrThreeTable',
      component: () => import('@/views/tableList/mgrThreeTable'),
      hidden: true,
      name: '300万以上项目情况列表',
      meta: { title: '300万以上项目情况列表' }
    },
    {
      path: '/login',
      component: () => import('@/views/login/index'),
      hidden: true
    },
    {
      path: '/tokenLogin',
      component: () => import('@/views/login/tokenLogin'),
      hidden: true,
      name: 'tokenLogin',
      meta: { title: '登录' }
    },
    {
      path: '/work',
      component: Layout,
      meta: { title: 'OKR管理', icon: 'el-icon-s-management', affix: true },
      children: [
        {
          path: 'departmentList',
          component: () => import('@/views/work/departmentList'),
          name: 'mytask',
          meta: { title: '部门OKR', affix: true }
        },
        {
          path: 'list',
          component: () => import('@/views/work/list'),
          name: 'work',
          meta: { title: '科室OKR' }
        },
        {
          path: 'mytask',
          component: () => import('@/views/work/mytask'),
          name: 'mytask',
          meta: { title: 'OKR待办' },
        },
        {
          path: 'workListNew',
          component: () => import('@/views/work/workListNew'),
          name: 'workListNew',
          meta: { title: 'OKR清单', noCache: true },
          // hidden: true
        },
        {
          path: 'myOkr',
          component: () => import('@/views/work/myOkr'),
          name: 'myOkr',
          meta: { title: '我的OKR' }
        },
        {
          path: 'detail/:id',
          component: workDetail,
          name: 'workDetail',
          meta: { title: '目标详情' },
          hidden: true,
        }
      ]
    },
    {
      path: '/supervisionImplementation',
      component: Layout,
      redirect: '/supervisionImplementation/list',
      meta: { title: '督办清单', icon: 'el-icon-star-on' },
      hidden: city !== '黑龙江省',
      children: [
        {
          path: 'list',
          component: () => import('@/views/work/supervisionImplementation'),
          name: 'supervisionImplementation',
          meta: { title: '督办派发' }
        },
        {
          path: 'supervisionImplementationListNew',
          component: () => import('@/views/work/supervisionImplementationListNew'),
          name: 'supervisionImplementationListNew',
          // hidden: true,
          meta: { title: '督办清单', noCache: true }
        },
        {
          path: 'leaderAssignedList',
          component: () => import('@/views/work/leaderAssignedList'),
          name: 'leaderAssignedList',
          meta: { title: '领导交办' }
        }
      ]
    },
    {
      path: '/network',
      component: Layout,
      redirect: '/network/net/customerList',
      meta: { title: '场景化商机调度', icon: 'el-icon-s-help' },
      children: [
        {
          path: 'net',
          meta: { title: '政务外网调度'},
          name: 'net',
          component: () => import('@/views/redirect'),
          children: [
            {
              path: '/network/net/customerList',
              component: () => import('@/views/tableList/customerList'),
              name: 'customerList',
              meta: { title: '客户清单' , noCache: true}
            },
            {
              path: 'businessOpportunitiesList',
              component: () => import('@/views/tableList/businessOpportunitiesList'),
              name: 'businessOpportunitiesList',
              meta: { title: '商机清单' , noCache: true}
            },
            {
              path: 'warnTable',
              component: () => import('@/views/tableList/warnTable'),
              name: 'warnTable',
              meta: { title: '商机预警' , noCache: true}
            },
            {
              path: 'list',
              component: () => import('@/views/work/network'),
              name: 'network',
              meta: { title: '调度指标派发', noCache: true }
            },
            {
              path: 'netTask',
              component: () => import('@/views/work/netTask'),
              name: 'netTask',
              meta: { title: '调度指标待办', noCache: true }
            },
            {
              path: 'cloudDetail/:id',
              component: () => import('@/views/work/cloudDetail'),
              name: 'cloudDetail',
              meta: { title: '目标详情' },
              hidden: true,
            },
          ]
        },
        {
          path: 'cloud',
          meta: { title: '政务云调度' },
          name: 'cloud',
          component: () => import('@/views/redirect'),
          children: [{
            path: 'customerListCloud',
            component: () => import('@/views/tableList/customerListCloud'),
            name: 'customerListCloud',
            meta: { title: '客户清单', noCache: true }
          },
          {
            path: 'businessOpportunitiesListCloud',
            component: () => import('@/views/tableList/businessOpportunitiesListCloud'),
            name: 'businessOpportunitiesListCloud',
            meta: { title: '商机清单', noCache: true }
          },
          {
            path: 'warnTableCloud',
            component: () => import('@/views/tableList/warnTableCloud'),
            name: 'warnTableCloud',
            meta: { title: '商机预警', noCache: true }
          },
          {
            path: 'cloudList',
            component: () => import('@/views/work/cloudwork'),
            name: 'cloudwork',
            meta: { title: '调度指标派发', noCache: true }
          },
          {
            path: 'netTaskCloud',
            component: () => import('@/views/work/netTask'),
            name: 'netTaskCloud',
            meta: { title: '调度指标待办', noCache: true }
          }]
        }
      ]
    },
    {
      path: '/featuredClients',
      component: Layout,
      redirect: '/featuredClients/dqytList',
      meta: { title: '特色客户商机调度', icon: 'el-icon-s-flag' },
      children: [
        {
          path: 'dqytList',
          component: () => import('@/views/tableList/dqytList'),
          name: 'dqytList',
          meta: { title: '大庆油田商机清单' },
        }
      ]
    },
    {
      path: '/superviseList',
      component: Layout,
      redirect: '/superviseList/list',
      meta: { title: '地市调度', icon: 'el-icon-s-order' },
      children: [
        {
          path: 'list',
          component: () => import('@/views/work/superviseList'),
          name: 'superviseListSend',
          meta: { title: '调度派发' }
        },
        {
          path: 'supervisetask',
          component: () => import('@/views/work/supervisetask'),
          name: 'supervisetask',
          meta: { title: '调度待办' }
        }
      ]
    },
    {
      path: '/weeklyReport',
      component: Layout,
      redirect: '/weeklyReport/list',
      meta: { title: '重点项目进展', icon: 'el-icon-s-claim' },
      children: [
        {
          path: 'list',
          component: () => import('@/views/work/weeklyReport'),
          name: 'weeklyReport',
          meta: { title: '交付项目进展' }
        },
        {
          path: 'ledger',
          component: () => import('@/views/work/solutionLedger'),
          name: 'solutionLedger',
          meta: { title: '丢标台账' }
        },
        {
          path: 'ganttDetail/:id',
          component: () => import('@/views/work/Gantt'),
          name: 'gantt',
          meta: { title: '重点项目进展详情' },
          hidden: true,
        },
        {
          path: 'loseBidDetail/:id',
          component: () => import('@/views/work/loseBidDetail'),
          name: 'loseBidDetail',
          meta: { title: '丢标台账详情' },
          hidden: true,
        }
      ]
    },
    {
      path: '/user',
      component: Layout,
      hidden: true,
      meta: { title: '用户管理', icon: 'el-icon-s-tools' },
      children: [
        {
          path: 'userList',
          component: () => import('@/views/work/userList'),
          name: 'userList',
          meta: { title: '用户管理', icon: 'el-icon-s-tools' }
        }
      ]
    },
    {
      path: '/userPdf',
      component: Layout,
      children: [
        {
          path: 'pdf',
          component: () => import('@/views/userPdf/pdf'),
          name: 'pdf',
          meta: { title: '用户手册', icon: 'el-icon-info' }
        }
      ]
    },
    {
      path: '/404',
      component: () => import('@/views/error-page/404'),
      hidden: true
    },
    {
      path: '/401',
      component: () => import('@/views/error-page/401'),
      hidden: true
    }
  ]
}
const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}
export default router

